/*
 * @Author: Allan
 * @Date: 2022-05-23 15:16:19
 * @LastEditors: Allan
 * @LastEditTime: 2022-05-23 15:16:36
 * @FilePath: \studygo\leecode\common\结构体.go
 * @Description: 定义leetcode中常用的结构体和函数
 *
 * Copyright (c) 2022 by Allan / ganger@whut.edu.cn, All Rights Reserved.
 */
package common

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}


func produceATree() TreeNode {
	/*
			3
			/ \
		   9  20
			 /  \
			15   7
	*/
	return TreeNode{
		Val: 3,
		Left: &TreeNode{
			Val:   9,
			Left:  nil,
			Right: nil,
		},
		Right: &TreeNode{
			Val: 20,
			Left: &TreeNode{
				Val:   15,
				Left:  nil,
				Right: nil,
			},
			Right: &TreeNode{
				Val:   7,
				Left:  nil,
				Right: nil,
			},
		},
	}
}
func produceATree2() TreeNode {
	/*
		          1
		         /
		        2
		       / \
		      4   5
			 /   /
		    5   4
	*/
	return TreeNode{
		Val: 1,
		Left: &TreeNode{
			Val: 2,
			Left: &TreeNode{
				Val: 4,
				Left: &TreeNode{
					Val:   5,
					Left:  nil,
					Right: nil,
				},
				Right: nil,
			},
			Right: &TreeNode{
				Val: 5,
				Left: &TreeNode{
					Val:   4,
					Left:  nil,
					Right: nil,
				},
				Right: nil,
			},
		},
		Right: nil,
	}
}